package operation;

import book.Book;
import book.BookList;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User:何人亮
 * Date:2024-05-24
 * 22:33
 */
public class borrowoperation implements Ioperation{

    @Override
    public void work(BookList bookList) {
        System.out.println("调用借阅图书。。。");
        System.out.println("请输入你要借的图书：");
        Scanner scanner=new Scanner(System.in);
        String name=scanner.nextLine();
        for (int i = 0; i < bookList.getSizdUsed(); i++) {
            if(name.equals(bookList.getBooks(i).getName())){
               if(bookList.books[i].isBorrow()!=true){
                   bookList.books[i].setBorrow(true);
                   System.out.println("借阅成功");
                   return;
               }else{
                   System.out.println("该图书已借出");
                   return;
               }
            }
        }
        System.out.println("没有找到该图书");
    }
}
